<?php
namespace app\index\model;
use think\Db;
use think\Model;
/*社交*/
class Conversation extends Model{
	//偶遇列表
    public static function sel($where,$start,$limit){
        $nowTime=time();//获取现在时间
    	 $user_info=Db::name('user_info')
                    ->where($where)
    	           ->field('uid as nearby_id,nickname,userImg1 as userPhoto,char_length
(sef_desc) as sef_desc,type_id,age,gender,province,marriage,token_time,longitude,latitude,birthday,constellation,university')
                 ->order('uid desc')
    	           ->limit($start,$limit)->select();
            if(!empty($user_info)){
              foreach ($user_info as $k=> $val){
                    if(empty($val['userPhoto'])){
                       unset($user_info[$k]);
                    }  
               }  
            }
          if(!empty($user_info)){
              foreach ($user_info as $key => $value){
                    if($nowTime>$value['token_time']){
                       $user_info[$key]['status']='-1';//不在线
                    }
                 else{
                       $user_info[$key]['status']='1';//在线
                   }      
               }  
            }               
         return $user_info;
    }
   //社交好友
    public static function friendSel($follow_id){
      $user_info=Db::name('user_info')
                 ->field('uid as nearby_id,userPhoto,status,sef_desc,gender,city,birthday,constellation,university')
                   ->where('uid','in',$follow_id)
                   ->where('userFlag','1')
                 ->select();      
         return $user_info;
    }
     //我玩过的活动
    public static function actPlay($uid){
        $activityId=Db::name('activity_users')
                   ->field('activity_id')
                   ->where(['uids'=>$uid])
                   ->select();      
         return $activityId;
    }
}
